Skip to content

[FEATURE REQUEST] Drag a file or folder from Files onto the terminal to type its path - #56

Merged
Raiden-MeixElysia merged 1 commit into
ELY-Open-Source:mainfrom
2youg1:files-drag-to-terminal
Nov 2, 2026
Merged

Raiden-MeixElysia merged 1 commit into
ELY-Open-Source:mainfrom
2youg1:files-drag-to-terminal

Conversation

@2youg1

@2youg1 2youg1 commented Nov 1, 2026

Copy link
Copy Markdown

Type

  • [FEATURE REQUEST]: a new feature or an improvement

What and why

The Files panel's tree is click-to-open only: there is no quick way to get a file's path into the shell. This lets a row be dragged onto the terminal, where it is dropped; the node's absolute path is then typed at the cursor, kept literal for the session's shell and followed by a space, exactly as an OS file dropped on the terminal already is. Folders drag the same way.

How it works:

  • Ely's Tree rows already drag a TreeDrag value with the node's label as a ghost, but the type was pub(crate), and gpui dispatches an in-app drop only to listeners whose type matches the drag value's exactly. Lists: TreeDrag is public, so a drop past the tree's rows names the dragged node Ely-GPUI-Components#9 makes TreeDrag public with key()/label(); until it merges, the Ely dep is pinned by rev to that PR's branch (a one-line Cargo.toml/Cargo.lock change repoints it at the org's merge commit).
  • The terminal's root takes a second on_drop for TreeDrag next to the existing ExternalPaths one; gpui matches each drop by its type, so the two coexist.
  • The terminal emits the node's key as TerminalEvent::Dragged; the workspace resolves it through Files::path — a key only resolves for a node Files actually listed, so a drag from any other tree types nothing, logged — and TerminalView::type_paths types it with the drop's quoting, as a paste, so bracketed paste, selection clearing and IME behaviour are the drop's own.
  • The tree's rows keep their internal move handling unchanged; it is gated on TreeDrag's still-private owner.

PRD, TASKS (T139), the acceptance table and AGENTS.md's record hold the change.

How it was tested

  • scripts/check.sh on Windows 11: cargo fmt --check and cargo clippy --all-targets -- -D warnings pass; 404 of 405 tests pass, the one failure (term::shell::windows_tests::only_a_bare_cmd_typed_takes_the_marked_prompt) failing identically on a clean checkout of main on this machine, so it is environmental and pre-existing.
  • The house-rules half of check.sh (comment and 500-line rules) passes for the touched files; tasks/reviews.md stands 5 lines over on main already.
  • The quoting and typing core is the existing, tested term::drop path; the key→path resolver it now relies on is covered by files' tree-key tests.
  • Not yet done, and called out in the acceptance table: a manual drag from a row onto the terminal on macOS, Windows and Linux, watching the typed path and the app: … dragged onto the terminal / terminal …: 1 paths dropped log lines.

Checklist

  • The title starts with [FEATURE REQUEST], [BUG REPORT] or [Other]
  • Tests and the build pass locally (one pre-existing environmental failure, reproduced on main)
  • Docs are updated if behaviour changed (PRD, TASKS, acceptance table, AGENTS.md)

中文概述(供审核者参考)

功能:从右侧 Files 文件树中拖动文件或文件夹到终端区域,松开鼠标后,该路径会按当前会话 shell 的引号规则自动输入到命令行(与系统文件拖入终端的行为一致)。

实现要点:Ely 的 Tree 行本身已支持拖拽,但其拖拽值 TreeDrag 是 crate 私有类型,而 gpui 按类型精确分发 drop 事件,因此需要先合并配套 PR ELY-Open-Source/Ely-GPUI-Components#9(将其公开并导出)。本 PR 中终端注册了第二个 on_drop 接收该拖拽值,经 workspace 用 Files::path 解析出真实路径后,复用现有拖放的引号与粘贴逻辑输入路径。Ely 依赖暂时指向 fork 上的提交,待 Ely PR 合并后改回组织仓库的 rev。尚未在真机上手动验证拖拽操作,已在 acceptance 表中注明。

A file or folder dragged from the Files panel and dropped on the
terminal types its absolute path at the cursor, kept literal for the
session's shell and followed by a space, as a dropped OS file does.

Ely's Tree rows already drag a TreeDrag value, now public in
ELY-Open-Source/Ely-GPUI-Components#9; the terminal takes a second
on_drop for it, gpui matching each drop by its type, and the workspace
resolves the node's key through Files and types the path with the
drop's quoting. The Ely dep is pinned by rev to the PR's branch until
it merges.
@Raiden-MeixElysia
Raiden-MeixElysia merged commit 55552a0 into ELY-Open-Source:main Nov 2, 2026
@2youg1
2youg1 deleted the files-drag-to-terminal branch November 2, 2026 19:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants